package edu.humc.service.Impl;

import edu.humc.dao.RecycleMapper;
import edu.humc.pojo.Recycle;
import edu.humc.service.RecycleService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;
@Service("RecycleServiceImpl")
public class RecycleServiceImpl implements RecycleService {
    @Resource(name = "RecycleMapper")
    RecycleMapper recycleMapper;
    @Override
    public List<Recycle> SelectRecycleById(int id) {
        return recycleMapper.SelectRecycleById(id);
    }
    //    删除回收站内的内容

    @Override
    public boolean DeleteRecycleById(String mid) {
        if (recycleMapper.DeleteRecycleById(mid)>0) {
            return true;
        }
        return false;
    }
    //    通过留言Id查找留言内容
    @Override
    public Recycle SelectRecycleByMid(String mid) {
        return recycleMapper.SelectRecycleByMid(mid);
    }
    //    恢复留言

    @Override
    public boolean RecoverMessage(String mid) {
        Recycle recycle=SelectRecycleByMid(mid);
        int res=recycleMapper.RecoverMessage(recycle);
        if (res>0){
            DeleteRecycleById(mid);
            return true;
        }
        return false;
    }
}
